home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / cvs-1_3.lha / cvs-1.3 / lib / getopt.h < prev    next >
C/C++ Source or Header  |  1992-03-31  |  4KB  |  103 lines

  1. /* declarations for getopt
  2.    Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /* @(#)getopt.h 1.6 92/03/31 */
  19.  
  20. /* For communication from `getopt' to the caller.
  21.    When `getopt' finds an option that takes an argument,
  22.    the argument value is returned here.
  23.    Also, when `ordering' is RETURN_IN_ORDER,
  24.    each non-option ARGV-element is returned here.  */
  25.  
  26. extern char *optarg;
  27.  
  28. /* Index in ARGV of the next element to be scanned.
  29.    This is used for communication to and from the caller
  30.    and for communication between successive calls to `getopt'.
  31.  
  32.    On entry to `getopt', zero means this is the first call; initialize.
  33.  
  34.    When `getopt' returns EOF, this is the index of the first of the
  35.    non-option elements that the caller should itself scan.
  36.  
  37.    Otherwise, `optind' communicates from one call to the next
  38.    how much of ARGV has been scanned so far.  */
  39.  
  40. extern int optind;
  41.  
  42. /* Callers store zero here to inhibit the error message `getopt' prints
  43.    for unrecognized options.  */
  44.  
  45. extern int opterr;
  46.  
  47. /* Describe the long-named options requested by the application.
  48.    _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an
  49.    element containing a name which is zero.
  50.  
  51.    The field `has_arg' is:
  52.    0 if the option does not take an argument,
  53.    1 if the option requires an argument,
  54.    2 if the option takes an optional argument.
  55.  
  56.    If the field `flag' is nonzero, it points to a variable that is set
  57.    to the value given in the field `val' when the option is found, but
  58.    left unchanged if the option is not found.
  59.  
  60.    To have a long-named option do something other than set an `int' to
  61.    a compiled-in constant, such as set a value from `optarg', set the
  62.    option's `flag' field to zero and its `val' field to a nonzero
  63.    value (the equivalent single-letter option character, if there is
  64.    one).  For long options that have a zero `flag' field, `getopt'
  65.    returns the contents of the `val' field.  */
  66.  
  67. struct option
  68. {
  69.   char *name;
  70.   int has_arg;
  71.   int *flag;
  72.   int val;
  73. };
  74.  
  75. #if __STDC__
  76. extern const struct option *_getopt_long_options;
  77. #else
  78. extern struct option *_getopt_long_options;
  79. #endif
  80.  
  81. /* If nonzero, '-' can introduce long-named options.
  82.    Set by getopt_long_only.  */
  83.  
  84. extern int _getopt_long_only;
  85.  
  86. /* The index in GETOPT_LONG_OPTIONS of the long-named option found.
  87.    Only valid when a long-named option has been found by the most
  88.    recent call to `getopt'.  */
  89.  
  90. extern int option_index;
  91.  
  92. #if __STDC__
  93. int gnu_getopt (int argc, char **argv, const char *shortopts);
  94. int gnu_getopt_long (int argc, char **argv, const char *shortopts,
  95.              const struct option *longopts, int *longind);
  96. int gnu_getopt_long_only (int argc, char **argv, const char *shortopts,
  97.               const struct option *longopts, int *longind);
  98. #else
  99. int gnu_getopt ();
  100. int gnu_getopt_long ();
  101. int gnu_getopt_long_only ();
  102. #endif
  103.